home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5043 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.5 KB  |  52 lines

  1. Newsgroups: comp.lang.c++
  2. Path: cs.vu.nl!jalten
  3. From: jalten@cs.vu.nl (Alten JP)
  4. Subject: Re: Why Do I Use An Ampersand in Member Class Parameters?
  5. Nntp-Posting-Host: kits.cs.vu.nl
  6. References: <4emnv2$n5o@alcor.usc.edu> <4enaak$o1h@ubszh.fh.zh.ubs.com> <4ep9do$a31@qualcomm.com>
  7. Sender: news@cs.vu.nl
  8. Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
  9. Date: Thu, 1 Feb 1996 08:27:21 GMT
  10. X-Newsreader: TIN [version 1.2 PL2]
  11. Message-ID: <DM38tM.L3G.0.-s@cs.vu.nl>
  12.  
  13. Nasser Abbasi (nabbasi@qualcomm.com) wrote:
  14. : In article <4enaak$o1h@ubszh.fh.zh.ubs.com>, jis@ubszh.net.ch says...
  15. : >
  16. : >In article <4emnv2$n5o@alcor.usc.edu>, wawda@alcor.usc.edu (Abu Wawda) 
  17. : writes:
  18. : >|> class Simple
  19. : >|> {
  20. : >|> public:
  21. : >|>   Simple();
  22. : >|>   int operator += (const Simple &);
  23. : >|> private:
  24. : >|>   int data;
  25. : >|> };
  26. : >|> 
  27. : >|> I have seen many examples of this but I what I don't understand is 
  28. : why
  29. : >|> there is an amersand after Simple? I would wind up implementating the
  30. : >|> function as something like the following:
  31. : >
  32. [Flame ignored]
  33. : >Ian
  34. [Reflame ignored]
  35. : Nasser
  36.  
  37.  
  38. Using the & will pass the object as a reference to the function.
  39. This way not the whole object needs to be pushed on the stack,
  40. but just the pointer, while you can pretend you have the object,
  41. not the pointer. 
  42.  
  43. the keywork is _reference_
  44.  
  45. Jelle Paul
  46.  
  47. --
  48. +-------------------------------------------------------+
  49. | Jelle Paul Alten                |   jalten@cs.vu.nl   |
  50. | Vrije Universiteit Amsterdam    |                     |
  51. +-------------------------------------------------------+
  52.